package DimondExercises;

import java.util.Scanner;

/**
 * Created by venus on 11/09/14.
 */
public class DimondWthName {
    public static void main(String[] args) {

        System.out.println("How many asterisks would you like? (Please enter a number) ");
        int enteredNumber;

        //Read number of rows
        Scanner input = new Scanner(System.in);

        //Check if the number is valid
        try {
            enteredNumber = input.nextInt();
        } catch (Exception e) {
            System.out.println("Wrong number. Please try again.");
            return;
        }

        //printout the diamond
        DrawTopDiamond(enteredNumber);
        DrawName(enteredNumber);
        DrawButtonDiamond(enteredNumber);

    }

    private static void DrawName(int enteredNumber) {
        int spaceCount = ((2 * enteredNumber)-5)/2;
        for (int i = 0; i < spaceCount; i++) {
            System.out.print(" ");
        }
        System.out.print("Venus");
        System.out.println();
    }

    private static void DrawTopDiamond(int enteredNumber) {
        int spaceCount = enteredNumber - 1;
        int starCount = 1;

        //Decrease the number of rows so last row won't be created. Instead we want to enter our name in last row
        int numberOfRows = enteredNumber- 1;

        for (int rowCounts = 0; rowCounts < numberOfRows; rowCounts++) {
            for (int k = 0; k < spaceCount; k++) {
                System.out.print(" ");
            }

            for (int j = 0; j < starCount; j++) {
                System.out.print("*");
            }
            starCount += 2;
            spaceCount--;
            System.out.println();
        }
    }

    private static void DrawButtonDiamond(int enteredNumber) {
        int spaceCount = 1;
        int starCount = (2 * enteredNumber - 1) - 2;

        for (int rowCounts = 0; rowCounts < enteredNumber; rowCounts++) {
            for (int k = 0; k < spaceCount; k++) {
                System.out.print(" ");
            }

            for (int j = 0; j < starCount; j++) {
                System.out.print("*");
            }
            starCount -= 2;
            spaceCount++;
            System.out.println();
        }
    }
}
